package ua.pp.bizon.yandex.api;

import ua.pp.bizon.yandex.nb.PhotosFrame;
import ua.pp.bizon.yandex.nb.ProgressPanel;

import javax.swing.UIManager;

public class WindowManager {

	static {
		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private PhotosFrame frame;

	public ILogin login(boolean wait) {
		ILogin loginDialog = new ua.pp.bizon.yandex.nb.LoginCodeDialog(frame, true);
		if (wait) {
			loginDialog.waitUserData();
		} else {
			loginDialog.unblockingWaitUserData();
		}
		return loginDialog;
	}

	public IMainFrame mainFrame() {
		if (frame == null) {
			frame = new PhotosFrame();
		}
		return frame;
	}

	public ProgressPanel progressPanel() {
		return ((PhotosFrame) mainFrame()).getProgressPanel();
	}

}
